Skip to content

fix(#8169): DROP TYPE deregisters the type's ALIASES, so the dropped type is not re-serialised into schema.json - #8195

Merged
robfrank merged 2 commits into
mainfrom
fix/8169-drop-type-leaves-aliases
Sep 22, 2026
Merged

robfrank merged 2 commits into
mainfrom
fix/8169-drop-type-leaves-aliases

Conversation

@robfrank

@robfrank robfrank commented Sep 22, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #8169

Summary

LocalSchema.dropType removed exactly one key from the schema's shared type map - the type's own name - and
nothing anywhere removed the alias keys, which kept pointing at the dropped, bucket-less LocalDocumentType
instance. The damaging consequence is not the stale lookup: toJSON(), reached from saveConfiguration(),
iterates typeMap().values() and keys each entry by t.getName(), so the dropped instance - still reachable
through its surviving alias key - was written back into schema.json under its own name with an empty bucket
list, and came back alive, unusable, at the next open. The drop also resolves its argument through getType(),
which resolves aliases, so the raw argument was the wrong thing to compare and the wrong thing to remove
whenever the caller named the type by one of its aliases. The fix deregisters every name the type answers to,
with the two-argument remove(key, value) that setAliases already uses so a name since taken over by another
type is not taken away from it, and resolves the canonical name once up front for the three places in
dropType that were comparing the caller's string against a canonical one.

Test plan

  • mvn -o -pl engine test -Dtest=Issue8169DropTypeLeavesAliasesTest - 8 tests, all of which fail on main
  • mvn -o -pl engine test -Dtest='com.arcadedb.schema.*Test,MaterializedView*Test,ContinuousAggregate*Test' - 759 pass
  • mvn -o -pl engine clean test -DexcludedGroups=benchmark,vector,slow - 16177 tests, 0 failures, 22 skipped
  • Manual: CREATE DOCUMENT TYPE Order; ALTER TYPE Order ALIASES PO; DROP TYPE Order; then reopen the
    database - existsType("Order") and existsType("PO") both answer false, and schema.json carries only
    the surviving types
  • Manual: after that drop, ALTER TYPE Invoice ALIASES PO succeeds instead of being refused with
    "already used by type 'Order'"

Completeness

The invariant

After dropType returns, no key in the schema type map resolves to the dropped type instance - neither the
type's own name nor any of its aliases - and every guard inside dropType decides on the type's canonical
name rather than on the string the caller typed.

The sweep

Every mutation of the shared type map in the tree:

$ grep -rn "typeMap()\.\(put\|putIfAbsent\|remove\|clear\)" --include="*.java" . | grep "/src/main/java/"
engine/src/main/java/com/arcadedb/schema/TypeBuilder.java:185:      schema.typeMap().put(typeName, c);
engine/src/main/java/com/arcadedb/schema/LocalSchema.java:2514:        if (typeMap().remove(typeName) == null)
engine/src/main/java/com/arcadedb/schema/LocalSchema.java:3638:    typeMap().put(type.getName(), type);
engine/src/main/java/com/arcadedb/schema/LocalDocumentType.java:348:        if (schema.typeMap().putIfAbsent(newName, this) != null)
engine/src/main/java/com/arcadedb/schema/LocalDocumentType.java:376:          .executeInWriteLock(() -> schema.typeMap().remove(oldName, this));
engine/src/main/java/com/arcadedb/schema/LocalDocumentType.java:385:      schema.typeMap().remove(newName, this);
engine/src/main/java/com/arcadedb/schema/LocalDocumentType.java:575:          final LocalDocumentType owner = schema.typeMap().putIfAbsent(alias, this);
engine/src/main/java/com/arcadedb/schema/LocalDocumentType.java:589:          schema.typeMap().remove(alias, this);
engine/src/main/java/com/arcadedb/schema/LocalDocumentType.java:596:          schema.typeMap().remove(alias, this);

LocalSchema.java:2514 is the only remover that can leave a key behind, and it is the one this PR changes.
The LocalDocumentType sites are all two-argument removes already and all belong to rename() and
setAliases(), neither of which removes a type.

Every reader that iterates the map's values, which is what makes a stale key damaging rather than merely wrong:

$ grep -rn "typeMap()\.values()" --include="*.java" . | grep "/src/main/java/"
LocalSchema.java:2401:    return new ArrayList<>(new LinkedHashSet<>(typeMap().values()));   # getTypes()
LocalSchema.java:2539:        for (final LocalDocumentType type : typeMap().values()) {      # dropBucket() guard
LocalSchema.java:3586:    for (final DocumentType t : typeMap().values())                    # inside toJSON()
LocalSchema.java:4093:    for (final LocalDocumentType t : typeMap().values()) {
LocalSchema.java:4100:    for (final LocalDocumentType t : typeMap().values()) {

:3586 is the resurrection: it is the loop inside public synchronized JSONObject toJSON(), which
saveConfiguration() reaches through update(toJSON()) - and dropType's own finally calls
saveConfiguration(). :2401 is why getTypes() listed the dropped type, which is in turn why
CHECK DATABASE walked it: the run that proved the tests fail on main shows
DatabaseChecker.checkDocuments -> countType -> SchemaException: Type with name 'Order' was not found
in every suppressed stack.

Every caller of dropType in the tree:

$ grep -rn "dropType(" --include="*.java" . | grep "/src/main/java/" | grep -v dropVertexType
integration/.../OrientDBImporter.java:285 / :290       integration/.../XMLImporterFormat.java:146
network/.../RemoteSchema.java:129                      mongodbw/.../MongoDBCollectionWrapper.java:355
mongodbw/.../MongoDBDatabaseWrapper.java:308           engine/.../ContinuousAggregateBuilder.java:162
engine/.../MaterializedViewBuilder.java:151            engine/.../LocalSchema.java:1617 (copyType rollback)
engine/.../LocalSchema.java:1943 / :2038               engine/.../DropTypeStatement.java:95

All of them reach the single LocalSchema.dropType this PR fixes; RemoteSchema.dropType issues
DROP TYPE <name> as SQL and has no separate server path.

Entry-point coverage

Entry point Covered by fix? Covered by a test?
LocalSchema.dropType(<own name>) leaves alias keys in the map yes yes - dropTypeDeregistersTheTypeAliases
SQL DROP TYPE <name> -> DropTypeStatement.executeDDL -> dropType yes yes - sqlDropTypeDeregistersTheTypeAliasesAndFreesThemForAlterType
ALTER TYPE Other ALIASES <alias> refused after the drop (#8064's putIfAbsent) yes yes - anAliasFreedByDropTypeCanBeClaimedByAnotherType (API) and the SQL test above
drop -> saveConfiguration() -> toJSON() -> schema.json -> reopen yes yes - aDroppedTypeDoesNotComeBackAfterAReopen, which asserts the FILE and then the reopen
LocalSchema.dropType(<alias>): getType() resolves aliases, so the argument can be one yes yes - dropTypeThroughAnAliasDropsTheTypeItself
dropType(<alias>) vs the materialized-view guards, which compared the raw argument yes yes - dropTypeThroughAnAliasIsStillRefusedForAMaterializedViewSourceType
dropType(<alias>) vs the continuous-aggregate guards, source type and backing type yes yes - ...ForAContinuousAggregateSourceType and ...ForAContinuousAggregateBackingType, added in review cycle 1
dropType(<alias>) vs typeBeingDropped, compared against affectedType.getName() at LocalSchema.java:1785 yes argued - the suppressed call is reportPartitionSuitabilityAfterSchemaChange(), a diagnostic wrapped in its own catch (RuntimeException) that only logs; it has no observable hook to assert on. It now receives the same canonicalTypeName the guard tests do exercise
RemoteSchema.dropType (HTTP client) yes argued - network/.../RemoteSchema.java:129 issues DROP TYPE <name> as SQL; the server executes the path the SQL test covers
MongoDBCollectionWrapper.dropCollection / MongoDBDatabaseWrapper yes argued - both call the same LocalSchema.dropType; the Mongo surface exposes no way to set ALIASES, so the alias set is always empty there
OrientDBImporter / XMLImporterFormat yes argued - same method; the types they drop are ones they just created and carry no aliases
copyType rollback, MaterializedViewBuilder / ContinuousAggregateBuilder rollback yes argued - same method; the types dropped there were created moments earlier in the same call and carry no aliases
LocalDocumentType.rename() - moves the name key, leaves the alias keys n/a argued - the type still exists, so its aliases must keep resolving to it. remove(oldName, this) is name-only by design, and the comment at :376 explains the ordering
LocalDocumentType.setAliases() - deregisters the aliases the new set drops n/a argued - already a two-argument remove(alias, this) since #8064, covered by Issue8064SetAliasesAtomicReservationTest

Reachability

LocalSchema.dropType is the engine's only type-drop path (the caller grep above), it is reached by SQL
DROP TYPE through DropTypeStatement:95, and nothing gates it behind a flag. The changed lines run on every
drop: all eight tests fail on main and pass here. The two continuous-aggregate tests were additionally
checked against a build with only the two ca. guard comparisons reverted to the raw argument, and fail there
(Tests run: 2, Failures: 2), so they reach the branch they name.

Known gaps

Residual risk

  • A caller holding a reference to a type it has already dropped and then calling a mutator on it (setAliases,
    createProperty, ...) can still write entries back into the shared schema. That is a general property of
    stale dropped-type references and predates this issue; no SQL path reaches it, because every ALTER TYPE
    resolves the type by name first and a dropped name no longer resolves.
  • getTypeOrNull(typeName) for the guards runs before recordFileChanges takes the database write lock, so a
    concurrent rename landing between the resolution and the drop would make canonicalTypeName stale. That
    window existed before this change as well - the guards compared the raw argument, which a rename invalidates
    the same way - so it is narrowed, not widened. The removal itself is unaffected: it uses type.getName()
    read under the write lock.
  • Deliberate semantic decision, flagged for review: DROP TYPE <alias> now drops the whole type rather than
    being refused. The alternative would be to refuse it and require the canonical name. Dropping was chosen
    because it is what the code already did to the type's buckets, indexes and edge files before this PR - it
    simply failed to finish the job - so refusing would be a larger behaviour change than the issue asked for.

Adversarial pass

The Task tool is not available in this session, so the Phase 1.5 subagent could not be spawned; the pass was
run inline against the diff instead, which loses the independence it is meant to buy. Stating that plainly
rather than claiming a pass that did not happen. What it turned up, all verified by reading the tree:

  • Real, fixed here. dropType's argument can be an alias, because getType() resolves them. Three places
    compared or stored the caller's raw string: the materialized-view/continuous-aggregate guards, the
    typeBeingDropped suppression flag, and the map removal itself. The first lets DROP TYPE <alias> drop a
    view's source type out from under it. Covered by the table above.
  • Real, filed. A database already corrupted by the #8169 DROP TYPE alias leak keeps its bucket-less zombie type after the upgrade, silently until the first insert #8187, above.
  • Not real. "The dropped instance still carries its aliases field, so it could re-register itself." It
    cannot re-register on its own - nothing re-reads that field except setAliases, which only a caller holding
    a stale reference can invoke, and toJSON, which is only reached from the walk over typeMap().values()
    that the instance is no longer in. Left as residual risk above rather than cleared, since clearing the field
    would make the removal loop's own input disappear.
  • Not real. "Removing the aliases before the name opens a window in which the type is reachable by name but
    not by alias." The whole body runs inside recordFileChanges, which executes under the database write lock
    (see the comment at its recordingDepth++ line), the same lock setAliases and rename take for their
    reservations, so no concurrent DDL can observe the intermediate state.

Review cycles

Cycle 1 - 69621fb - claude reviewed and raised three points, all acted on:

  1. "there's no method named serializeConfiguration in this class; the actual call chain is
    saveConfiguration() -> toJSON()."
    Correct, and verified: grep -rn serializeConfiguration engine/src
    returned only my own comment, and the typeMap().values() loop sits inside
    public synchronized JSONObject toJSON(), which saveConfiguration() reaches through update(toJSON()).
    The name came from the issue report and I carried it over without checking it. Fixed in the production
    comment, the test class javadoc, the test's inline comment, and in this description.
  2. "the parallel ContinuousAggregateImpl guard path isn't exercised by an alias-specific test." Fair.
    Added dropTypeThroughAnAliasIsStillRefusedForAContinuousAggregateSourceType and
    ...ForAContinuousAggregateBackingType, and proved both can fail (see Reachability above).
  3. "the PR body describes a different change (Aggregation push-down reads MultiColumnAggregationRequest.columnIndex as a row index in the mutable half and a schema index in the sealed half #8140 time-series columnIndex)." Correct, and it was not
    what I wrote.
    A sibling agent working on Aggregation push-down reads MultiColumnAggregationRequest.columnIndex as a row index in the mutable half and a schema index in the sealed half #8140 overwrote this PR's description after it was opened,
    carrying the Closes #8169 line away with it and replacing it with Closes #8140 - so this PR was, for a
    while, pointed at the wrong issue and DROP TYPE leaves the type's ALIASES in the schema type map, so the dropped type is re-serialised into schema.json and comes back alive after a restart #8169 would not have auto-closed. It also overwrote my draft in the
    shared scratchpad directory, so the body below is a reconstruction rather than a restore. Flagging it
    because the accident is invisible unless a reviewer reads the body against the diff, and claude catching
    it is the only reason it was noticed.

codacy-production reported 0 new issues. coderabbitai hit its OSS review limit on 69621fb and posted no
findings.

Cycle 2 - c294d60 - claude re-reviewed the amended head and found nothing blocking: "solid,
well-scoped fix with unusually thorough regression coverage and an honest accounting of what isn't covered. No
blocking issues found."
It independently confirmed the three things the fix turns on - that toJSON() at
~3586 keys typeMap().values() by t.getName(), that typeBeingDropped is compared at :1785 against a
canonical name so passing canonicalTypeName there is consistent rather than incidental, and that
getAliases() hands back a volatile Set.copyOf(...) snapshot so the removal loop cannot tear or throw
against a concurrent setAliases. It also noted that setAliases already refuses a type aliasing its own
name, so the alias loop and the canonical removal cannot fight over one map entry.

Nothing was applied in cycle 2 and nothing was deferred: its three "minor / non-blocking" notes (the two
typeMap() lookups, the pre-lock resolution window, and the DROP TYPE <alias> semantics) each agree with a
position already stated under Residual risk, and it asked for no change. Working tree empty, no open review
threads, so the loop exits here.

Deferred items

None from the reviewer. One process note for the maintainer: CodeRabbit never reviewed this PR. It was rate
limited on 69621fb ("You've used all free OSS reviews for now") and its check on c294d60 reports
Review rate limited rather than a pass over the diff, so pulls/8195/reviews and pulls/8195/comments are
both empty. Nothing is unresolved, because nothing was ever raised - but this PR has had one bot reviewer, not
two, which is worth knowing before merging.

🤖 Generated with Claude Code

…type is not re-serialised into schema.json

LocalSchema.dropType removed exactly one key from the schema's shared type map - the type's own name - and
nothing removed the alias keys, which kept pointing at the dropped, bucket-less LocalDocumentType instance.
serializeConfiguration() iterates typeMap().values() and keys each entry by t.getName(), so the dropped
instance - still reachable through its surviving alias key - was written back into schema.json under its own
name with an empty bucket list and came back alive, unusable, at the next open. It also kept existsType(alias)
answering true, made a later ALTER TYPE ... ALIASES refuse the alias while naming a type that no longer
existed, and left the instance in getTypes(), which is what CHECK DATABASE walks.

The drop resolves its argument through getType(), which resolves aliases, so the raw argument was also the
wrong thing to compare: DROP TYPE <alias> walked past the materialized-view and continuous-aggregate guards
and past the typeBeingDropped suppression, both of which compare against a canonical name.

Deregister every name the type answers to, with the two-argument remove(key, value) setAliases already uses so
a name since taken over by another type is not taken away from it, and resolve the canonical name once up
front for the guards and the suppression flag.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 3 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 37941ff2-257e-4608-91f3-7348b9f2dba7

📥 Commits

Reviewing files that changed from the base of the PR and between 382ae09 and c294d60.

📒 Files selected for processing (2)
  • engine/src/main/java/com/arcadedb/schema/LocalSchema.java
  • engine/src/test/java/com/arcadedb/schema/Issue8169DropTypeLeavesAliasesTest.java

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@mergify

mergify Bot commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

@codacy-production

codacy-production Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Coverage 100.00% diff coverage · -6.19% coverage variation

Metric Results
Coverage variation ✅ -6.19% coverage variation
Diff coverage ✅ 100.00% diff coverage

View coverage diff in Codacy

Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (382ae09) 187750 156313 83.26%
Head commit (c294d60) 220299 (+32549) 169765 (+13452) 77.06% (-6.19%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#8195) 10 10 100.00%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@claude

claude Bot commented Sep 22, 2026

Copy link
Copy Markdown

Review

Solid, well-targeted fix. LocalSchema.dropType previously only removed the type's own key from typeMap(), so a surviving alias key kept the dropped LocalDocumentType instance reachable - toJSON()/saveConfiguration() (referenced in the new comment as serializeConfiguration(), see note below) re-serialized it into schema.json under its own name with an empty bucket list, existsType(alias) kept answering true, and a later ALTER TYPE ... ALIASES refused a name that no longer belonged to anything. Deregistering every name the instance answers to (type.getAliases() + type.getName()), and resolving the canonical name once up front for the materialized-view/continuous-aggregate guards and typeBeingDropped, closes all three symptoms cleanly.

Correctness

  • typeMap() stores aliases as keys pointing at the same instance (confirmed via LocalDocumentType.setAliases), so getTypeOrNull(typeName) at LocalSchema.java:2447 is a correct, lock-free way to resolve a possible alias to the canonical name before the guards run.
  • Using remove(key, value) rather than plain remove(key) for both the alias cleanup and the final canonical removal is the right call - it avoids yanking a name back from a type that reclaimed it after this one was dropped, consistent with the same pattern in setAliases's unwind path.
  • The whole thing runs inside recordFileChanges(...), which the codebase documents as running under the database write lock, so there's no window for a concurrent setAliases/dropType to race the alias-set snapshot taken via type.getAliases().
  • typeBeingDropped = canonicalTypeName correctly fixes the line ~1785 comparison (affectedType.getName().equals(typeBeingDropped)), which previously wouldn't suppress the partition-suitability report when the type was dropped by an alias.

Nit

  • The new comment at LocalSchema.java:2528 says the alias key is re-serialized "which serializeConfiguration() ... writes back into schema.json" - there's no method by that name in this class; the actual call chain is saveConfiguration() -> toJSON(). Worth fixing so a future grep for serializeConfiguration doesn't come up empty.

Test coverage

Good breadth: in-memory dedup (existsType/getTypeOrNull/getTypes()), alias reuse by another type, the SQL DDL path, on-disk persistence across a reopen, and drop-by-alias tearing down the real type. One gap: the materialized-view alias guard is tested (dropTypeThroughAnAliasIsStillRefusedForAMaterializedViewSourceType), but the parallel ContinuousAggregateImpl guard path (ca.getBackingTypeName()/ca.getSourceTypeName()) isn't exercised by an alias-specific test - the code is symmetric so risk is low, but a quick companion test would close the loop the same way the materialized-view one does.

PR description mismatch

The PR title and diff are about issue #8169 (DROP TYPE/aliases), but the PR body's summary, test plan, and "Coverage"/"Adversarial pass" sections all describe a different change - a MultiColumnAggregationRequest.columnIndex convention fix for time-series aggregation (#8140), referencing files (TimeSeriesEngine, TimeSeriesSealedStore, SelectExecutionPlanner, etc.) that don't appear in this diff at all. Looks like the wrong body got attached to this PR - worth fixing so the description matches what's actually being merged.

Note: I wasn't able to execute mvn in this review environment (build commands require interactive approval unavailable here), so this review is based on static reading of the diff rather than running the test suite described in the (mismatched) PR body.

…t, and cover the continuous-aggregate alias guards

The comment carried "serializeConfiguration()" over from the issue report; no such method exists in
LocalSchema. The loop that re-serialised the dropped type lives in toJSON(), which saveConfiguration()
reaches through update(toJSON()). Corrected in the production comment, the test javadoc and the test's
inline comment.

The materialized-view alias guard had a test and its continuous-aggregate twin did not. Added one for the
source type and one for the backing type; both fail against a build with only the two ca. comparisons
reverted to the raw argument, so they reach the branch they name.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@claude

claude Bot commented Sep 22, 2026

Copy link
Copy Markdown

Review

I read the change against the surrounding code (guard call sites, typeMap(), LocalDocumentType.getAliases()/setAliases(), getTypeOrNull/getType, and the typeBeingDropped consumer at LocalSchema.java:1785) rather than the diff in isolation. Note: I wasn't able to run mvn in this sandbox (build commands required approval that wasn't available), so this is a static review; the PR description's own test-run output looks credible and matches what the code does.

Correctness — looks right

  • The root cause analysis holds up: typeMap() is keyed by both a type's canonical name and every alias (LocalDocumentType.setAliases reserves alias keys with putIfAbsent), but the old dropType only ever removed typeMap().remove(typeName) — one key. Confirmed toJSON() (LocalSchema.java:~3586) iterates typeMap().values() and keys by t.getName(), so a surviving alias key really would resurrect the dropped instance on the next saveConfiguration().
  • Using remove(key, value) instead of remove(key) is the right call — it mirrors the pattern setAliases() already uses, and correctly avoids stealing a name that has since been reassigned to another type in the (rare) case of a stale reference.
  • The canonicalTypeName resolution is correct: getType()/getTypeOrNull() just do a raw typeMap().get(...), so an alias and a canonical name are genuinely indistinguishable to those guards without this resolution step. Good catch that this affects three separate call sites (MV/CA guards, typeBeingDropped, and the final removal) — I checked typeBeingDropped is compared at line 1785 against affectedType.getName(), i.e. a canonical name, so passing canonicalTypeName there is consistent rather than incidental.
  • Confirmed setAliases() refuses a type aliasing its own name (throws SchemaException for owner == this), so there's no risk of the new alias-removal loop and the final canonical-name removal fighting over the same map entry.
  • getAliases() returns a volatile Set.copyOf(...) snapshot, so iterating it in the removal loop while another thread could theoretically call setAliases() concurrently is safe (no ConcurrentModificationException, and no torn read).
  • User-facing exception messages still use the raw typeName the caller passed (not the resolved canonical name), which is the right UX call — it keeps error messages truthful to what the user typed.

Test coverage — thorough

The new test class covers the direct bug (existsType/getType on aliases after drop, getTypes() no longer double-listing), the persistence round-trip (asserting the on-disk schema.json content, not just post-reopen state), the alias-reuse case from #8064's putIfAbsent, dropping through an alias, and both MV/continuous-aggregate guards being bypass-proof via an alias. This is good regression coverage and each test's docstring explains what would fail pre-fix and why, which will help future maintainers understand intent quickly.

One gap acknowledged directly in the PR description that's worth flagging for visibility rather than blocking: the fix doesn't repair a schema.json already corrupted by this bug in an existing database (filed as #8187). That seems like the right scope decision for this PR, but worth confirming it gets tracked before this ships to a release actually consumed by users with existing databases.

Minor / non-blocking

  • dropType now does two lookups against typeMap() for the same typeName — once via getTypeOrNull up front, once via getType inside recordFileChanges. This is a single hashmap get, so no real perf concern, and splitting it this way is arguably necessary since the guard checks intentionally run before the write-lock is acquired (same structure as before this change). Not asking for a change here, just noting it for anyone scanning for redundancy.
  • The residual-risk callout about a stale rename racing between the pre-lock getTypeOrNull resolution and the in-lock removal is honestly stated as a pre-existing, narrowed (not widened) window rather than something newly introduced — agree with that framing based on reading recordFileChanges's write-lock semantics.
  • The semantic decision to let DROP TYPE <alias> drop the whole type (rather than refusing and requiring the canonical name) is reasonable given buckets/indexes were already being torn down in that case pre-fix; flagging it as "deliberate, flagged for review" in the description is the right way to surface it for maintainer sign-off.

Style / conventions

  • Matches the file's existing convention of long, load-bearing "WHY" comments in caps for non-obvious invariants — consistent with the rest of LocalSchema.java.
  • Uses final throughout new locals/params, no unnecessary braces on single-statement ifs, no new dependencies — consistent with CLAUDE.md guidance.
  • No System.out debug output left behind.

Overall: solid, well-scoped fix with unusually thorough regression coverage and an honest accounting of what isn't covered. No blocking issues found.

@codecov

codecov Bot commented Sep 22, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 60.00000% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.93%. Comparing base (382ae09) to head (c294d60).

Files with missing lines Patch % Lines
...src/main/java/com/arcadedb/schema/LocalSchema.java 60.00% 0 Missing and 4 partials ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##               main    #8195   +/-   ##
=========================================
  Coverage     74.92%   74.93%           
  Complexity     2602     2602           
=========================================
  Files          2004     2004           
  Lines        187750   187754    +4     
  Branches      39270    39272    +2     
=========================================
+ Hits         140677   140695   +18     
+ Misses        31476    31464   -12     
+ Partials      15597    15595    -2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DROP TYPE leaves the type's ALIASES in the schema type map, so the dropped type is re-serialised into schema.json and comes back alive after a restart

1 participant